#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
const int N = 1e5 + 10;

int n;
int q[N], tr[N];

int lowbit(int x){
    return (-x) & x;
}

void add(int x, int k){
    for(int i = x; i <= n; i += lowbit(i)) tr[i] += k;
}

int f(int x){
    int res = 0;
    for(int i = x; i > 0; i -= lowbit(i)) res += tr[i];
    return res;
}